package com.chainyoung.component_tmperson.ui.mvp.presenter;

import com.chainyoung.common.base.CommonSubscriber;
import com.chainyoung.common.mvp.BasePresenter;
import com.chainyoung.common.utils.RxUtils;
import com.chainyoung.component_tmperson.entity.WalletFinancing;
import com.chainyoung.component_tmperson.entity.WalletFinancingOwn;
import com.chainyoung.component_tmperson.ui.mvp.contract.WalletFinancingMangeContract;
import com.chainyoung.component_tmperson.ui.mvp.contract.WalletFinancingTradeContract;

import java.util.List;
import java.util.TreeMap;

import javax.inject.Inject;

public class WalletFinancingTradePresenter extends BasePresenter<WalletFinancingTradeContract.Model, WalletFinancingTradeContract.View> {

    @Inject
    public WalletFinancingTradePresenter(WalletFinancingTradeContract.Model model, WalletFinancingTradeContract.View rootView) {
        super(model, rootView);
    }


    public void getUserFinancingProfit(TreeMap<String, Object> map) {

        addSubscribe(mModel.getUserFinancingProfit(map)
                .compose(RxUtils.<WalletFinancingOwn>rxSchedulerHelper())
                .subscribeWith(new CommonSubscriber<WalletFinancingOwn>(mView, true) {
                    @Override
                    public void onNext(WalletFinancingOwn data) {
                        mView.onGetUserFinancingProfitSuccess(data);
                    }

                    @Override
                    public void onError(Throwable e) {
                        mView.onGetUserFinancingProfitFailed();
                        super.onError(e);
                    }
                }));
    }


    public void turnIn(TreeMap<String, Object> map) {

        addSubscribe(mModel.turnIn(map)
                .compose(RxUtils.<String>rxSchedulerHelper())
                .subscribeWith(new CommonSubscriber<String>(mView, true) {
                    @Override
                    public void onNext(String data) {
                        mView.onTurnInSuccess(data);
                    }

                    @Override
                    public void onError(Throwable e) {
                        super.onError(e);
                    }
                }));
    }


}




